package com.ycz.pattern.structure.adapterpattern;

/**
 * @Description
 * @ClassName MediaAdapter
 * @Author yanchengzhi
 * @date 2023.11.22 01:12
 */
public class MediaAdapter implements MediaPlayer {

    AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String type) {
        if("vlc".equalsIgnoreCase(type)) {
            advancedMediaPlayer = new VlcPlayer();
        } else if("mp4".equalsIgnoreCase(type)) {
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String type, String fileName) {
        if("vlc".equalsIgnoreCase(type)) {
            advancedMediaPlayer.playVlc(fileName);
        } else if("mp4".equalsIgnoreCase(type)) {
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
